{% extends ../base.html %}

{% block head %}
<style>
.code-analyze-name a {
    /*color: #FF5000;*/
    color: blue;
}
.code-analyze-line {
    color: green;
    padding-left: 10px;
    margin-left: 10px;
    white-space: pre;
}
table td {
    border:none;
}
</style>
{% end %}

{% block body %}
<div class="col-md-12">&nbsp;</div>
<div>
    <form action="">
        <table>
        <tr>
            <td>路径</td>
            <td><textarea name="path" cols=100>{{?path}}</textarea></td>
        </tr>
        <tr>
            <td>关键字</td>
            <td><textarea name="key" cols=100>{{?key}}</textarea></td>
        </tr>
        <tr>
            <td>文件名</td>
            <td><textarea name="filename" cols=100>{{?filename}}</textarea></td>
        </tr>
        <tr>
            <td>忽略大小写</td>
            <td><input type="checkbox" name="ignore_case" {% if ignore_case == "on" %} checked {% end %}/></td>
        </tr>
        <tr>
            <td>递归搜索</td>
            <td><input type="checkbox" name="recursive" {% if recursive == "on" %} checked {% end %}/></td>
        </tr>
        </table>
        <div>
            <button>查询</button>
            <a href="/code/lines?path={{path}}">统计</a>
            <a href="/code/encode?path={{path}}">加密</a>
        </div>
    </form>
</div>


{{?error}}

{% if len(files) > 0 %}
<div class="col-md-12">
    匹配文件数: {{len(files)}}
</div>
{% end %}

{% for file in files %}

<div class="row">
    <div style="float:right;">匹配数: {{len(file.result)}}</div>
    <div class="code-analyze-name">
        <a href="/code/view_source?path={{file.name}}&key={{key}}" target="_blank">{{file.name}}</a>
    </div>
    <div>

        {% for line in file.result %}
            <div>
                <code class="code-analyze-line">{{line}}</code>
            </div>
        {% end %}

    </div>
    <br/>
</div>

{% end %}
{% end %}